<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class InformationController extends HomeController
{
//获取介绍子导航栏目
	public function type_list(){
	$category=D('Channel');
	$where['pid']=13;
	$where['status']=1;
    $category_list = $category->where($where)->select();
	return $category_list;
	}
	//系统首页
    public function index()
    {
		$category_list=$this->type_list();
		$this->assign('category_list', $category_list);

		
		$information=D('DocumentInformation');
		$document=D('Document');
		$where['category_name']=0;
		$group=$information->where($where)->field('id')->order('id desc')->select();
		
		
		$count      = count($group);// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出
		 //进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list =$information->where($where)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->field('id')->select();
		
		//$this->assign('list',$list);// 赋值数据集
		//$this->assign('page',$show);// 赋值分页输出
	
		  foreach($list as  $k => $v){
            $group_id =  $v['id'];
            $condition=[
                'id'     =>  $group_id ,
                'status' => 1
            ];
		
            $six_upload[] = $document->where($condition)->field('id , cover_id , title')->select();
			 $group_list[] = $six_upload[$k];
				
        }
        $group_lists=$group_list;
		$this->assign('show',  $show);
		$this->assign('list',  $group_lists);
        $this->display('index');
    }
	
	 public function industry()
    {
		$category_list=$this->type_list();
		$this->assign('category_list', $category_list);
		
		$information=D('DocumentInformation');
		$document=D('Document');
		$where['category_name']=1;
		$group=$information->where($where)->field('id')->order('id desc')->select();
		
		
		$count      = count($group);// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出
		 //进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list =$information->where($where)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->field('id')->select();
		
		//$this->assign('list',$list);// 赋值数据集
		//$this->assign('page',$show);// 赋值分页输出
	
		  foreach($list as  $k => $v){
            $group_id =  $v['id'];
            $condition=[
                'id'     =>  $group_id ,
                'status' => 1
            ];
		
            $six_upload[] = $document->where($condition)->field('id , cover_id , title')->select();
			 $group_list[] = $six_upload[$k];
				
        }
        $group_lists=$group_list;
		
		$this->assign('show',  $show);
		$this->assign('list',  $group_lists);
        $this->display('index');
    }
	
	
	 public function newscontent()
    {
		$category_list=$this->type_list();
		$this->assign('category_list', $category_list);
		
		$news_id=$_GET['id'];
		$information=D('DocumentInformation');
		$document=D('Document');
		$where['id']=$news_id;
		$news_title=$document->where($where)->select();
		$news_content=$information->where($where)->field('content')->select();
        $this->assign('news_title',  $news_title);
		$this->assign('news_content',  $news_content);
        $this->display('newscontent');
    }
	

}